package com.test;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * Project: tobe-better-coder
 * Package: com.test
 *
 * @author : Mr.xu
 * @date : 2023/9/23 20:58
 */
public class HomeWork {
    public static void main(String[] args) throws Exception {
        Class aClass = Class.forName("main.pojo.CatHomeWork");
        Object o = aClass.newInstance();
        Field field = aClass.getDeclaredField("name");
//        field.setAccessible(true);
//        field.set(o,"中国猫");
        Method method = aClass.getMethod("getName");
        System.out.println(method.invoke(o));


        Method methodPrivate = aClass.getDeclaredMethod("privateGetName");
        System.out.println(method.invoke(o));

    }
}